import { CommentLoadCondition, CommentPage } from "@/model/CommentModel"
import axios from "axios"


export const loadResourceCommentsAPI = async (commentLoadCondition: CommentLoadCondition):
    Promise< CommentPage | null > => {
         console.log(`API加载资源id为 ${commentLoadCondition.resourceId} 页数为 ${commentLoadCondition.pageIndex} 的评论数据...`)
    try {
        // 发送搜索资源请求
        const response = await axios.post('/api/comment/getResourceComment', 
            commentLoadCondition, 
            { headers: { 'Content-Type': 'application/json' } }
        )
        console.log("后端返回的数据：", response.data)              //调试
        return response.data
    } catch (error) {
        // 搜索资源失败，捕获异常
        console.error('获取资源数据失败:', error)
        return null 
    }
}